import pymysql
class Db:
    def __init__(self):
        self.conn=pymysql.connect(hosty='localhost',port=3306,user='root',
        password='131421',db='hali',charset='utf8',cursorclass=pymysql.cousors.DictCursor)
        self.cousor=self.conn.cursor()

# 添加, 修改 ,删除
def uddate(self,sql):
    self.coursor.execute(sql)
    self.conn.commit()

#查询单个
def find(self,sql):
    self.cousor.execute(sql)
    res = self.cousor.fetchone()
    return res
#查询所有
def findall(self,sql):
    self.cousor.execute(sql)
    res = self.cousor.fetchall()
    return res

#关闭
def close(self):
    self.cousor.close()
    self.conn.close()
db1=Db()